import { customRef } from 'vue'
import { arrToObj } from '@/utils/handleData'
import { TASK_INSPECTS } from '@/utils/dictionary'

export default function(data) {
  const list = [
    {
      label: '任务编号',
      value: data.inspectionCode
    },
    {
      label: '任务名称',
      value: data.inspectionName
    },
    {
      label: '巡检部门',
      value: data.deptName
    },
    {
      label: '巡检方式',
      value: arrToObj(TASK_INSPECTS, 'value', 'label')[data.inspectionType]
    },
    {
      label: '巡检设备',
      value: data.equipmentName
    },
    {
      label: '巡检开始时间',
      value: data.executionStartTime
    },
    {
      label: '巡检结束时间',
      value: data.executionEndTime
    },
    {
      label: '巡检航道',
      value: data.channelName
    }
  ]

  return customRef((track, trigger) => {
    return {
      get() {
        track()
        return list
      }
    }
  })
}
